/**
 * 所有页面都会载入的 js
 */
import * as filters from '@/common/filters'
import directives from '@/common/directives'
import ajax from '@/common/Ajax'
import Modal from '@/common/Modal'
import Toast from '@/common/Toast'
import Message from '@/common/Message'
import LoadingBar from '@/common/LoadingBar'
import MyPanel from '@/components/MyPanel'
// 注册所有 filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// 注册所有 directives
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})
Vue.component("MyPanel",MyPanel);
Vue.prototype.$ajax = ajax
Vue.prototype.$LoadingBar = LoadingBar
Vue.prototype.$Modal = Modal
Vue.prototype.$Toast = Toast
Vue.prototype.$Message = Message.install;
Vue.prototype.$HasPermission = filters.btnPermissionControl;
Vue.mixin({
  computed:{
    $baseSize(){
      return Number(document.documentElement.style.fontSize.replace("px",""))
    }
  }
})
/**
 * 以下为所有页面通用
 */

if ('addEventListener' in document) {
  document.addEventListener(
    'DOMContentLoaded',
    function() {
      //FastClick.attach(document.body)
    },
    false
  )
}
document.addEventListener("visibilitychange", function(){
  //浏览器切换到非显示状态
  if(document.visibilityState=='hidden'){
    //停止视频播放
    let video = $("video")[0];
    video&&video.pause();
  }
});
